<?php
include('includes/connect.php');
if($_POST['subcat'])
{
$id=$_POST['subcat'];
$sql=mysql_query("SELECT * FROM subcategories AS s, categories AS c WHERE c.category_id = s.category_id and s.category_id = '$id'");
echo '<option selected="selected" value="">Select</option>';
while($row=mysql_fetch_array($sql))
{
$id=$row['subcategory_id'];
$data=$row['subcategory'];
echo '<option value="'.$id.'">'.$data.'</option>';
}
}

?>